//
//  BaseController.m
//  Gift
//
//  Created by dllo on 15/9/10.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "BaseController.h"
#import "LDSearchBar.h"
#import "BaseHeader.h"

@interface BaseController ()

@end

@implementation BaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];
    self.navigationController.navigationBar.translucent = NO;
    [self setTitle:@"礼物说"];
     [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20.], NSForegroundColorAttributeName:[UIColor colorWithRed:1.000 green:1.000 blue:1.000 alpha:1.000]}];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

    
     UIImage *bigmass = [UIImage imageNamed:@"iconfont-fangdajing"];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:bigmass style:UIBarButtonItemStylePlain target:self action:@selector(rightClick)];

 
    //消息中心夜间模式
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleChange:) name:@"lidi" object:nil];
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString *passWord = [user objectForKey:@"night"];
    if ([passWord isEqualToString:@"yes"]) {
        [self.view setBackgroundColor:BACKG_NIGHT];
        [self.navigationController.navigationBar setBarTintColor:NAV_NIGHT];
    }
}


- (void)handleChange:(NSNotification *)Notification{
    
    NSString *passWord = [Notification object];
    if ([passWord isEqualToString:@"yes"]) {
        [self.view setBackgroundColor:BACKG_NIGHT];
        [self.navigationController.navigationBar setBarTintColor:NAV_NIGHT];
    }else if ([passWord isEqualToString:@"no"]){
        [self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];
        [self.view setBackgroundColor:[UIColor whiteColor]];
    }
    
}



-(void)rightClick
{
    LDSearchBar *search = [[LDSearchBar alloc]init];
    [self.navigationController pushViewController: search animated:YES];
    
    [search release];
};


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
